using System.Windows.Forms;

namespace DEVPROM.Feedback
{
	public partial class ProxyAuthForm : Form
	{
		public ProxyAuthForm()
		{
			InitializeComponent();
		}

		public string UserName
		{
			get { return _getItemAt(1); }
		}

		private string _getItemAt(int index)
		{
			try
			{
				string text = textBoxLogin.Text.Trim();
				if (string.IsNullOrEmpty(text)) return "";

				string[] items = text.Split(new char[] { '\\' });
				if (index < items.GetLength(0)) return items[index];
			}
			catch (System.Exception)
			{
				return "";
			}

			return "";
		}

		public string Password
		{
			get { return textBoxPassword.Text.Trim(); }
		}

		public string Domain
		{
			get { return _getItemAt(0); }
		}

		private void buttonOK_Click(object sender, System.EventArgs e)
		{
			Properties.Settings.Default.Save();
		}

		private void textBoxPassword_KeyUp(object sender, KeyEventArgs e)
		{
			if (e.KeyCode == Keys.Enter) buttonOK.PerformClick();
		}
	}
}